#pragma once

#include "znx_mem.h"

typedef znx_mem_freelists_t             znx_thread_mem_freelists_t;
typedef znx_4kaligned_mem_freelists_t   znx_thread_4kaligned_mem_freelists_t;


znx_thread_mem_freelists_t *
znx_thread_mem_freelists_create(size_t water_level);

void *
znx_thread_mem_freelists_alloc(znx_thread_mem_freelists_t *freelists, size_t size);

void
znx_thread_mem_freelists_free(znx_thread_mem_freelists_t *freelists, void *ptr);

void
znx_thread_mem_freelists_clean(znx_thread_mem_freelists_t *freelists);

void
znx_thread_mem_freelists_destroy(znx_thread_mem_freelists_t *freelists);

void
znx_thread_mem_freelists_status_report(
    znx_thread_mem_freelists_t *freelists, char *buf, size_t buf_size);

static inline void *
znx_thread_mem_freelists_calloc(znx_thread_mem_freelists_t *freelists, size_t size)
{
    void *ptr = znx_thread_mem_freelists_alloc(freelists, size);
    bzero(ptr, size);
    return ptr;
}



znx_thread_4kaligned_mem_freelists_t *
znx_thread_4kaligned_mem_freelists_create(size_t water_level);

void *
znx_thread_4kaligned_mem_freelists_alloc(
    znx_thread_4kaligned_mem_freelists_t *freelists, size_t size);

void
znx_thread_4kaligned_mem_freelists_free(
    znx_thread_4kaligned_mem_freelists_t *freelists, void *ptr);

void
znx_thread_4kaligned_mem_freelists_clean(znx_thread_4kaligned_mem_freelists_t *freelists);

void
znx_thread_4kaligned_mem_freelists_destroy(
    znx_thread_4kaligned_mem_freelists_t *freelists);

void
znx_thread_4kaligned_mem_freelists_status_report(
    znx_thread_4kaligned_mem_freelists_t *freelists,
    char *buf, size_t buf_size);
